// import { configureStore } from '@reduxjs/toolkit';
 
// // 引入 slice 文件
// import counterSlice from './counterSlice';
 
// // 配置 store，并引入 slice
// const store = configureStore({
//   reducer: {
//     counter: counterSlice.reducer,
//   },
// });
 
// export default store;

import { configureStore } from "@reduxjs/toolkit";
import { useDispatch,useSelector } from "react-redux";

//引入切片reducer
import CarReducer from "./CarSliceReducer"
import counterSlice from './counterSlice';

//创建store对象
const store=configureStore({
  //引入所有的reducer模块对象
  reducer:{
    car:CarReducer,
     counter: counterSlice,
  }
})

//仓库的状态
export type RootState = ReturnType<typeof store.getState>
export type AppDispatch = typeof store.dispatch
//重写useSelector、useDispatch
export const useAppDispatch = useDispatch.withTypes<AppDispatch>()
export const useAppSelector = useSelector.withTypes<RootState>()

//抛出store对象
export default store
